from apscheduler.schedulers.blocking import BlockingScheduler
import time


def job1():
    print(f"定时任务--- {time.strftime('%Y-%m-%d %H:%M:%S')}")


def job2(name):
    print(f"定时任务 带参数... {name}: {time.strftime('%Y-%m-%d %H:%M:%S')}")


scheduler = BlockingScheduler()
# 每3,5s秒执行一次
scheduler.add_job(job1, "interval", seconds=3)
scheduler.add_job(job2, "interval", seconds=5, args=("每隔5s",))
# 使用CRON表达式，每天12点执行
scheduler.add_job(job1, "cron", hour=12)

try:
    scheduler.start()
except (KeyboardInterrupt, SystemExit):
    pass

print("end---------")
